package com.skb.core.dao;

import com.skb.core.model.InterestRate;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

@Repository("interestRateDao")
public class InterestRateDaoImpl implements InterestRateDao {

    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public InterestRate create(InterestRate interestRate) {
        sessionFactory.getCurrentSession().persist(interestRate);
        return interestRate;
    }

    @Override
    public InterestRate get(Serializable id) {
        return (InterestRate) sessionFactory.getCurrentSession().get(InterestRate.class, id);
    }

    @Override
    public InterestRate update(InterestRate interestRate) {
        sessionFactory.getCurrentSession().update(interestRate);
        return interestRate;
    }

    @Override
    public void delete(InterestRate interestRate) {
        sessionFactory.getCurrentSession().delete(interestRate);
    }
}
